﻿#include "Frm01.h"

Frm01::Frm01(HmiApp* app, STTWidget *par, const string& id, const string& desc) : STTPage(app->getRuntime(), par, id, desc) {
	hmiApp = app;
}

Frm01::~Frm01() {
}

void Frm01::onInit(){
}

void Frm01::createParts() {
	setMainArg(0, 0, 1024, 600);
	setMainStyle(0, 0xffffff, 0xffffff, 0, 255, 0, 0xc0c0c0);

	/*----------------------------- Label : wMLabel2                     -----------------------------*/
	wMLabel2 = new STTLabel(p_rt, this, "wMLabel2");
	wMLabel2->setMainArg(222, 116, 593, 84, "智能宠物管家", TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMLabel2->setFonts(0x0, 36, "文泉驿微米黑", 0);
	wMLabel2->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 0, 0x0, 0);
	wMLabel2->setFormatText(TextAlign::CENTER, LabelLongMode::CLIP, 30);

	/*----------------------------- Label : wMLabel3                     -----------------------------*/
	wMLabel3 = new STTLabel(p_rt, this, "wMLabel3");
	wMLabel3->setMainArg(179, 549, 682, 49, "武汉鑫通态科技有限公司（提供HMI屏和解决方案18086668733）", TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMLabel3->setFonts(0x0, 16, "文泉驿微米黑", 0);
	wMLabel3->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 0, 0x0, 0);
	wMLabel3->setFormatText(TextAlign::CENTER, LabelLongMode::CLIP, 30);

	/*----------------------------- Image : wMImage1                     -----------------------------*/
	wMImage1 = new STTImage(p_rt, this, "wMImage1");
	wMImage1->setMainArg(187, 556, 36, 36);
	wMImage1->addStateImg("0", "./images/img17493739620632_36X36R0.png");

	/*----------------------------- Label : wMLabel4                     -----------------------------*/
	wMLabel4 = new STTLabel(p_rt, this, "wMLabel4");
	wMLabel4->setMainArg(0, 200, 512, 180, "", TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMLabel4->setFonts(0x0, 72, "文泉驿微米黑", 0);
	wMLabel4->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 0, 0x0, 0);
	wMLabel4->setFormatNumerical(1, false, 1, 0.1, 0.0, 0, false, "", "");
	wMLabel4->bindData(_V("温度"));

	/*----------------------------- Label : wMLabel5                     -----------------------------*/
	wMLabel5 = new STTLabel(p_rt, this, "wMLabel5");
	wMLabel5->setMainArg(511, 199, 512, 180, "", TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMLabel5->setFonts(0x0, 72, "文泉驿微米黑", 0);
	wMLabel5->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 0, 0x0, 0);
	wMLabel5->setFormatNumerical(1, false, 1, 0.1, 0.0, 0, false, "", "");
	wMLabel5->bindData(_V("湿度"));

	/*----------------------------- Label : wMLabel6                     -----------------------------*/
	wMLabel6 = new STTLabel(p_rt, this, "wMLabel6");
	wMLabel6->setMainArg(155, 396, 201, 25, "当前温度(°C)", TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMLabel6->setFonts(0x0, 16, "文泉驿微米黑", 0);
	wMLabel6->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 0, 0x0, 0);
	wMLabel6->setFormatText(TextAlign::CENTER, LabelLongMode::CLIP, 30);

	/*----------------------------- Label : wMLabel7                     -----------------------------*/
	wMLabel7 = new STTLabel(p_rt, this, "wMLabel7");
	wMLabel7->setMainArg(670, 396, 192, 25, "当前湿度(%)", TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMLabel7->setFonts(0x0, 16, "文泉驿微米黑", 0);
	wMLabel7->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 0, 0x0, 0);
	wMLabel7->setFormatText(TextAlign::CENTER, LabelLongMode::CLIP, 30);

	/*----------------------------- Button : wMButton1                   -----------------------------*/
	wMButton1 = new STTButton(p_rt, this, "wMButton1", 0);
	wMButton1->setMainArg(13, 1, 98, 48, false);
	wMButton1->setPressedArg("mp3", 0x0, "文泉驿微米黑", 16, 0);
	wMButton1->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton1->setReleasedArg("mp3", 0x0, "文泉驿微米黑", 12, 0);
	wMButton1->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton1->bindOpenFormHandler(Event::CLICKED, "Frm02", PageMode::NEWWIN, NULL);

	/*----------------------------- Button : wMButton2                   -----------------------------*/
	wMButton2 = new STTButton(p_rt, this, "wMButton2", 0);
	wMButton2->setMainArg(113, 1, 98, 48, false);
	wMButton2->setPressedArg("mp4", 0x0, "文泉驿微米黑", 16, 0);
	wMButton2->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton2->setReleasedArg("mp4", 0x0, "文泉驿微米黑", 12, 0);
	wMButton2->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton2->bindOpenFormHandler(Event::CLICKED, "Frm03", PageMode::NEWWIN, NULL);

	/*----------------------------- Button : wMButton3                   -----------------------------*/
	wMButton3 = new STTButton(p_rt, this, "wMButton3", 0);
	wMButton3->setMainArg(213, 1, 98, 48, false);
	wMButton3->setPressedArg("语音合成", 0x0, "文泉驿微米黑", 16, 0);
	wMButton3->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton3->setReleasedArg("语音合成", 0x0, "文泉驿微米黑", 12, 0);
	wMButton3->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton3->bindOpenFormHandler(Event::CLICKED, "Frm04", PageMode::NEWWIN, NULL);

	/*----------------------------- Button : wMButton4                   -----------------------------*/
	wMButton4 = new STTButton(p_rt, this, "wMButton4", 0);
	wMButton4->setMainArg(313, 1, 98, 48, false);
	wMButton4->setPressedArg("孵化日记", 0x0, "文泉驿微米黑", 16, 0);
	wMButton4->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton4->setReleasedArg("孵化日记", 0x0, "文泉驿微米黑", 12, 0);
	wMButton4->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton4->bindOpenFormHandler(Event::CLICKED, "Frm07", PageMode::NEWWIN, NULL);

	/*----------------------------- Button : wMButton5                   -----------------------------*/
	wMButton5 = new STTButton(p_rt, this, "wMButton5", 0);
	wMButton5->setMainArg(413, 1, 98, 48, false);
	wMButton5->setPressedArg("对症下药", 0x0, "文泉驿微米黑", 16, 0);
	wMButton5->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton5->setReleasedArg("对症下药", 0x0, "文泉驿微米黑", 12, 0);
	wMButton5->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton5->bindOpenFormHandler(Event::CLICKED, "Frm06", PageMode::NEWWIN, NULL);

	/*----------------------------- Button : wMButton6                   -----------------------------*/
	wMButton6 = new STTButton(p_rt, this, "wMButton6", 0);
	wMButton6->setMainArg(513, 1, 98, 48, false);
	wMButton6->setPressedArg("闹钟", 0x0, "文泉驿微米黑", 16, 0);
	wMButton6->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton6->setReleasedArg("闹钟", 0x0, "文泉驿微米黑", 12, 0);
	wMButton6->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton6->bindOpenFormHandler(Event::CLICKED, "Frm08", PageMode::NEWWIN, NULL);

	/*----------------------------- Button : wMButton7                   -----------------------------*/
	wMButton7 = new STTButton(p_rt, this, "wMButton7", 0);
	wMButton7->setMainArg(613, 1, 98, 48, false);
	wMButton7->setPressedArg("监控摄像头", 0x0, "文泉驿微米黑", 16, 0);
	wMButton7->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton7->setReleasedArg("监控摄像头", 0x0, "文泉驿微米黑", 12, 0);
	wMButton7->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton7->bindOpenFormHandler(Event::CLICKED, "Frm09", PageMode::NEWWIN, NULL);

	/*----------------------------- Button : wMButton8                   -----------------------------*/
	wMButton8 = new STTButton(p_rt, this, "wMButton8", 0);
	wMButton8->setMainArg(713, 1, 98, 48, false);
	wMButton8->setPressedArg("功能键", 0x0, "文泉驿微米黑", 16, 0);
	wMButton8->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton8->setReleasedArg("功能键", 0x0, "文泉驿微米黑", 12, 0);
	wMButton8->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);

	/*----------------------------- Button : wMButton9                   -----------------------------*/
	wMButton9 = new STTButton(p_rt, this, "wMButton9", 0);
	wMButton9->setMainArg(813, 1, 98, 48, false);
	wMButton9->setPressedArg("趋势图表", 0x0, "文泉驿微米黑", 16, 0);
	wMButton9->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton9->setReleasedArg("趋势图表", 0x0, "文泉驿微米黑", 12, 0);
	wMButton9->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton9->bindOpenFormHandler(Event::CLICKED, "Frm10", PageMode::NEWWIN, NULL);

	/*----------------------------- Button : wMButton10                  -----------------------------*/
	wMButton10 = new STTButton(p_rt, this, "wMButton10", 0);
	wMButton10->setMainArg(913, 1, 98, 48, false);
	wMButton10->setPressedArg("设置", 0x0, "文泉驿微米黑", 16, 0);
	wMButton10->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton10->setReleasedArg("设置", 0x0, "文泉驿微米黑", 12, 0);
	wMButton10->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton10->bindOpenFormHandler(Event::CLICKED, "Frm05", PageMode::NEWWIN, NULL);

	/*called after widget created.*/

	return; //createParts END
}

#include "util/StringUtil.h"

void Frm01::onLoad(){
	string bu = KVUtil::getVal("温度补偿","0");
	int ii = StringUtil::safeStoi(bu);
	wMLabel4->setFormatNumerical(2, false, 1, 0.1, ii/100.0, 0, false, "", "");

	string bu2 = KVUtil::getVal("湿度补偿","0");
	int ii2 = StringUtil::safeStoi(bu2);
	wMLabel5->setFormatNumerical(2, false, 1, 0.1, ii2/100.0, 0, false, "", "");
}

bool Frm01::onClosing(){
	return true;
}

void Frm01::onDispose(){
}
